//
//  StoryIcon.m
//  宝宝儿歌
//
//  Created by Clement_Gu on 16/4/25.
//  Copyright © 2016年 baobaoerge. All rights reserved.
//

#import "StoryIcon.h"



@implementation StoryIcon

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
      self.btn =  [self buildButton:@"icon-144" ];
        
      self.label =  [self buildLabel:@"儿歌"];
      
    }

    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.btn.frame = CGRectMake(self.bounds.size.width*0.5-70, self.bounds.size.height*0.5 -115, 140, 200);
    self.label.frame = CGRectMake(self.bounds.size.width*0.5-70, CGRectGetMaxY(self.btn.frame), 140, 30);

}

-(UIButton *)buildButton:(NSString *)image
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnPress) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    return btn;
}

-(UILabel *)buildLabel:(NSString *)title
{
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.text = title;
    nameLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:nameLabel];
    return nameLabel;
}

-(void)btnPress
{
    [self.delegate btnClickWillPress];
}




@end
